<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>		
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<link rel="shortcut icon" href="/resources/favicon.ico" type="image/x-icon"/>
		<link rel="stylesheet" type="text/css" href="/resources/styles.css">
		<script type="text/javascript" src="resources/jquery-1.7.2.min.js"></script>
		<title>Homegrown Cuisine - Login</title>				
	</head>	
	<body background="">		
		<h1>Login</h1>

		<a href="/">Back</a>
		
		<div id="userAccountDiv">
			<form name="f" action="/admin/j_spring_security_check" method="POST">
		      <table>
		        <tr><td>User:</td><td><input type='text' name='j_username' value='<c:if test="${not empty param.login_error}"><c:out value="${SPRING_SECURITY_LAST_USERNAME}"/></c:if>'/></td></tr>
		        <tr><td>Password:</td><td><input type='password' name='j_password'></td></tr>		        
		        <tr><td colspan='2'><input name="submit" type="submit" title="Login"></td></tr>
		        <tr><td colspan='2'><input name="reset" type="reset"></td></tr>
		      </table>
    		</form>
		</div>		
	</body>	
</html>
 <script type="text/javascript">
	$(document).ready(function() {
	  	$('input:submit[title=Login]')
								.click(
										function(event) {
											$('.errorLoginMail').hide();
											$('.errorLoginPasscode').hide();
											
											var loginName = $('input[name=j_username]');
											var loginPassword = $('input[name=j_password]');
											
											// Validating loginName
											if (loginName.val() == '') {
												loginName
														.after('<span class="errorLoginMail" style="color:red;">Please enter your login name.</span>');
												event.preventDefault();
											}
											
											// Validating loginPassword
											if (loginPassword.val() == '') {
												loginPassword
														.after('<span class="errorLoginPasscode" style="color:red;">Please enter your password.</span>');
												event.preventDefault();
											}

										})
	});
</script> 